<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>键盘事件</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <div id = "root">
        <h1>你好</h1>
        <!---->
        <input type="text" placeholder="请输入内容" @keyup = "showInfo"/>
<!--使用自定义别名  不推荐-->
        <input type="text" placeholder="请输入内容" @keyup.huiche = "showInfo2"/>
    </div>
</body>
<script type="text/javascript">
    //自定义回车键别名
   Vue.config.keyCodes.huiche = 13
    new Vue({
      el:'#root', 
      data: { 
      },
      methods: {
        showInfo(e){
            if(e.keyCode ==13){
                console.log(e.target.value);
            }
            
        },
        showInfo2(e){
            
                console.log(e.target.value);
            
            
        }
      },
    })
</script>
</html>